core: Add allocating b64 checksum functions
authorDan Nicholson <nicholson@endlessm.com>
Thu, 14 Jul 2016 16:09:12 +0000 (09:09 -0700)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 15 Jul 2016 02:18:27 +0000 (02:18 +0000)
The checksum_b64_inplace variants can't be used in bindings. Provide
versions that allocate and return the output rather than working on a
passed in buffer. These can then be used in GI bindings to get the
ostree modified base64 encodings.

Closes: #398
Approved by: cgwalters

apidoc/ostree-sections.txt
src/libostree/libostree.sym
src/libostree/ostree-core.c
src/libostree/ostree-core.h

index cc77f15a4be75fae059a7387f0626a4d922aabd2..8b6337f701b46c194eea71fa170e05034d7d6bd9 100644 (file)
@@ -99,6 +99,8 @@ ostree_checksum_inplace_from_bytes
 ostree_checksum_inplace_to_bytes
 ostree_checksum_bytes_peek
 ostree_checksum_bytes_peek_validate
+ostree_checksum_b64_from_bytes
+ostree_checksum_b64_to_bytes
 ostree_checksum_b64_inplace_from_bytes
 ostree_checksum_b64_inplace_to_bytes
 ostree_cmp_checksum_bytes
index f26be3f0475d50a65f2ed6e2ac630f9d1a61ce77..04e364535d78e4ce7378915977f313b8c0be27dd 100644 (file)
@@ -351,9 +351,8 @@ global:
  *                         NOTE NOTE NOTE
  */
 
-/* UNCOMMENT WHEN ADDING THE FIRST NEW SYMBOL FOR 2016.8
 LIBOSTREE_2016.8 {
 global:
-       insert_symbol_here;
+        ostree_checksum_b64_to_bytes;
+        ostree_checksum_b64_from_bytes;
 } LIBOSTREE_2016.7;
-*/ 
index 32f0fd449ea4d8837f929b211a10545b28b1fcc9..bf4d62a879690b6f13b79ab32dafbbdd6f3c1b28 100644 (file)
@@ -1272,6 +1272,20 @@ ostree_checksum_to_bytes_v (const char *checksum)
   return ot_gvariant_new_bytearray ((guchar*)result, OSTREE_SHA256_DIGEST_LEN);
 }
 
+/**
+ * ostree_checksum_b64_to_bytes:
+ * @checksum: An ASCII checksum
+ *
+ * Returns: (transfer full) (array fixed-size=32): Binary version of @checksum.
+ */
+guchar *
+ostree_checksum_b64_to_bytes (const char *checksum)
+{
+  guchar *ret = g_malloc (32);
+  ostree_checksum_b64_inplace_to_bytes (checksum, ret);
+  return ret;
+}
+
 /**
  * ostree_checksum_inplace_from_bytes: (skip)
  * @csum: (array fixed-size=32): An binary checksum of length 32
@@ -1363,6 +1377,23 @@ ostree_checksum_from_bytes_v (GVariant *csum_v)
   return ostree_checksum_from_bytes (ostree_checksum_bytes_peek (csum_v));
 }
 
+/**
+ * ostree_checksum_b64_from_bytes:
+ * @csum: (array fixed-size=32): An binary checksum of length 32
+ *
+ * Returns: (transfer full): Modified base64 encoding of @csum
+ *
+ * The "modified" term refers to the fact that instead of '/', the '_'
+ * character is used.
+ */
+char *
+ostree_checksum_b64_from_bytes (const guchar *csum)
+{
+  char *ret = g_malloc (44);
+  ostree_checksum_b64_inplace_from_bytes (csum, ret);
+  return ret;
+}
+
 /**
  * ostree_checksum_bytes_peek:
  * @bytes: #GVariant of type ay
index 415369d5484bf518d3056430fef0d1fcacfee4f7..d1f76cf17b3fd036611e02c81e24c03785355673 100644 (file)
@@ -192,6 +192,8 @@ guchar *ostree_checksum_to_bytes (const char *checksum);
 _OSTREE_PUBLIC
 GVariant *ostree_checksum_to_bytes_v (const char *checksum);
 _OSTREE_PUBLIC
+guchar *ostree_checksum_b64_to_bytes (const char *checksum);
+_OSTREE_PUBLIC
 void ostree_checksum_b64_inplace_to_bytes (const char *checksum,
                                            guint8     *buf);
 
@@ -199,6 +201,8 @@ _OSTREE_PUBLIC
 char * ostree_checksum_from_bytes (const guchar *csum);
 _OSTREE_PUBLIC
 char * ostree_checksum_from_bytes_v (GVariant *csum_v);
+_OSTREE_PUBLIC
+char * ostree_checksum_b64_from_bytes (const guchar *csum);
 
 _OSTREE_PUBLIC
 void ostree_checksum_inplace_from_bytes (const guchar *csum,